Add tests for --exclude
authortorkleyy <thomas-schaller2000@gmx.de>
Fri, 12 May 2017 13:44:15 +0000 (15:44 +0200)
committertorkleyy <thomas-schaller2000@gmx.de>
Sat, 27 May 2017 18:33:00 +0000 (20:33 +0200)
tests/bench.rs
tests/build.rs
tests/test.rs

index e706256189c7cef5fffe8d082308ef7d907065dc..96b30aa1cac1634f0d705579beae2666e31c23da 100644 (file)
@@ -1011,6 +1011,61 @@ fn bench_all_workspace() {
                        .with_stdout_contains("test bench_foo ... bench: [..]"));
 }
 
+#[test]
+fn bench_all_exclude() {
+    if !is_nightly() { return }
+
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.1.0"
+
+            [workspace]
+            members = ["bar", "baz"]
+        "#)
+        .file("src/main.rs", r#"
+            fn main() {}
+        "#)
+        .file("bar/Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.1.0"
+        "#)
+        .file("bar/src/lib.rs", r#"
+            #![feature(test)]
+
+            extern crate test;
+
+            #[bench]
+            pub fn bar(b: &mut test::Bencher) {
+                b.iter(|| {});
+            }
+        "#)
+        .file("baz/Cargo.toml", r#"
+            [project]
+            name = "baz"
+            version = "0.1.0"
+        "#)
+        .file("baz/src/lib.rs", r#"
+            #[test]
+            pub fn baz() {
+                break_the_build();
+            }
+        "#);
+
+    assert_that(p.cargo_process("bench")
+                    .arg("--all")
+                    .arg("--exclude")
+                    .arg("baz"),
+                execs().with_status(0)
+                    .with_stdout_contains("\
+running 1 test
+test bar ... bench:           0 ns/iter (+/- 0)
+
+test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured"));
+}
+
 #[test]
 fn bench_all_virtual_manifest() {
     if !is_nightly() { return }
index fc4d289832b443b76c9e8d41970cb67470f69ab5..20f0d4b376d4e37e6cacd3d7813d52bf41f07d9e 100644 (file)
@@ -2803,6 +2803,49 @@ fn build_all_workspace() {
                        [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n"));
 }
 
+#[test]
+fn build_all_exclude() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.1.0"
+
+            [workspace]
+            members = ["bar", "baz"]
+        "#)
+        .file("src/main.rs", r#"
+            fn main() {}
+        "#)
+        .file("bar/Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.1.0"
+        "#)
+        .file("bar/src/lib.rs", r#"
+            pub fn bar() {}
+        "#)
+        .file("baz/Cargo.toml", r#"
+            [project]
+            name = "baz"
+            version = "0.1.0"
+        "#)
+        .file("baz/src/lib.rs", r#"
+            pub fn baz() {
+                break_the_build();
+            }
+        "#);
+
+    assert_that(p.cargo_process("build")
+                 .arg("--all")
+                 .arg("--exclude")
+                 .arg("baz"),
+                execs().with_status(0)
+                       .with_stderr("[..] Compiling bar v0.1.0 ([..])\n\
+                       [..] Compiling foo v0.1.0 ([..])\n\
+                       [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n"));
+}
+
 #[test]
 fn build_all_workspace_implicit_examples() {
     let p = project("foo")
index 473e63472cfa224eaf4ef29b417b467b3ef343bf..07edf1952e87b5d4f8b2a79d47e648c63b08fa67 100644 (file)
@@ -2377,6 +2377,52 @@ fn test_all_workspace() {
                        .with_stdout_contains("test bar_test ... ok"));
 }
 
+#[test]
+fn test_all_exclude() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.1.0"
+
+            [workspace]
+            members = ["bar", "baz"]
+        "#)
+        .file("src/main.rs", r#"
+            fn main() {}
+        "#)
+        .file("bar/Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.1.0"
+        "#)
+        .file("bar/src/lib.rs", r#"
+            #[test]
+            pub fn bar() {}
+        "#)
+        .file("baz/Cargo.toml", r#"
+            [project]
+            name = "baz"
+            version = "0.1.0"
+        "#)
+        .file("baz/src/lib.rs", r#"
+            #[test]
+            pub fn baz() {
+                assert!(false);
+            }
+        "#);
+
+    assert_that(p.cargo_process("test")
+                    .arg("--all")
+                    .arg("--exclude")
+                    .arg("baz"),
+                execs().with_status(0)
+                    .with_stdout_contains("running 1 test
+test bar ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured"));
+}
+
 #[test]
 fn test_all_virtual_manifest() {
     let p = project("workspace")